package com.yanfan.iot.model;

import lombok.Builder;
import lombok.Data;

import java.util.Objects;

/**
 * mqtt配置信息
 */

@Data
@Builder
public class MqttClientConfig {

    private Long key;

    private String name;
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 连接地址
     */
    private String hostUrl;
    /**
     * 客户Id
     */
    private String clientId;
    /**
     * 默认连接话题
     */
    private String defaultTopic;
    /**
     * 超时时间
     */
    private int timeout;
    /**
     * 保持连接数
     */
    private int keepalive;

    /**
     * 是否清除session
     */
    private boolean clearSession;
    /**
     * 是否共享订阅
     */
    private boolean isShared;
    /**
     * 分组共享订阅
     */
    private boolean isSharedGroup;

    /**
     * 是否是临时连接
     */
    private boolean isTemp;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MqttClientConfig that = (MqttClientConfig) o;

        if (timeout != that.timeout) return false;
        if (keepalive != that.keepalive) return false;
        if (clearSession != that.clearSession) return false;
        if (isShared != that.isShared) return false;
        if (isSharedGroup != that.isSharedGroup) return false;
        if (isTemp != that.isTemp) return false;
        if (!Objects.equals(key, that.key)) return false;
        if (!Objects.equals(name, that.name)) return false;
        if (!Objects.equals(username, that.username)) return false;
        if (!Objects.equals(password, that.password)) return false;
        if (!Objects.equals(hostUrl, that.hostUrl)) return false;
        if (!Objects.equals(clientId, that.clientId)) return false;
        return Objects.equals(defaultTopic, that.defaultTopic);
    }
}

